import Vue from 'vue'
import VueRouter from "vue-router";
import ClubList from "@/components/clubAdmin/ClubList";
import ClubAdd from "@/components/clubAdmin/ClubAdd";
import ClubTypeList from "@/components/clubAdmin/ClubTypeList";
import Carousel from "@/components/fileAdmin/Carousel";
import MainAdmin from "@/components/MainAdmin";
import MainCom from "@/components/MainCom";
import Login from "@/components/Login";
import ArticleList from "@/components/articleCom/ArticleList";
import ArticleAdd from "@/components/articleCom/ArticleAdd";
import ArticleTypeList from "@/components/articleCom/ArticleTypeList";
import ActivityAdd from "@/components/activityCom/ActivityAdd";
import ActivityList from "@/components/activityCom/ActivityList";
import ActivityTypeList from "@/components/activityCom/ActivityTypeList";
import PersonList from "@/components/personCom/PersonList";
import ClubInfo from "@/components/personCom/ClubInfo";
import Index from "@/components/Index";
import IndexA from "@/components/reception/IndexA";
import ArticleA from "@/components/reception/ArticleA";
import ActivityA from "@/components/reception/ActivityA";
import ArticleB from "@/components/reception/ArticleB";
import ArticleC from "@/components/reception/ArticleC"
import ActivityB from "@/components/reception/ActivityB";
import ActivityC from "@/components/reception/ActivityC";
import ClubA from "@/components/reception/ClubA";
import ClubB from "@/components/reception/ClubB";
import ClubC from "@/components/reception/ClubC";
import ClubApplicant from "@/components/reception/ClubApplicant";
import Applicant from "@/components/personCom/Applicant";
import Search from "@/components/reception/Search";
import ArticleListAdmin from "@/components/articleCom/ArticleListAdmin";
import ActivityListAdmin from "@/components/activityCom/ActivityListAdmin";

Vue.use(VueRouter);

const router = new VueRouter({
    mode: "history",
    routes: [
        // 前台
        {
            path:'/',
            component: Index,
            children: [
                {
                    path: '/',
                    component: IndexA,
                },
                {
                    path: '/articleA',
                    component: ArticleA,
                    children:[
                        {
                            path:'',
                            component: ArticleC
                        },
                        {
                            path: '/articleA/articleB',
                            component: ArticleB
                        }
                    ]
                },
                {
                    path: '/activityA',
                    component: ActivityA,
                    children: [
                        {
                            path: '',
                            component: ActivityC
                        },
                        {
                            path: '/activityA/activityB',
                            component: ActivityB,
                        }
                    ]
                },
                {
                    path: '/clubA',
                    component: ClubA,
                    children:[
                        {
                            path: '/',
                            component: ClubC
                        },
                        {
                            path: '/clubA/clubB',
                            component: ClubB
                        }
                    ]
                },
                {
                    path: '/clubApplicant',
                    component: ClubApplicant
                },
                {
                    path: '/search',
                    component: Search
                }
            ]
        },

        {
            path: '/login',
            component: Login
        },
        // 后台
        {
            path: '/mainAdmin',
            component: MainAdmin,
            children: [
                {
                path: '/club/list',
                component: ClubList
                },
                {
                    path: '/club/add',
                    component: ClubAdd
                },
                {
                    path: '/club/typelist',
                    component: ClubTypeList
                },
                {
                    path: '/file/carousel',
                    component: Carousel
                },
                {
                    path: '/club/articleTypeList',
                    component: ArticleTypeList
                },
                {
                    path: '/club/activityTypeList',
                    component: ActivityTypeList
                },
                {
                    path: '/club/article',
                    component: ArticleListAdmin
                },
                {
                    path: '/club/activity',
                    component: ActivityListAdmin
                }
            ]
        },
        // com
        {
            path: '/mainCom',
            component: MainCom,
            children: [
                {
                    path: '/mainCom/articleList',
                    component: ArticleList
                },
                {
                    path: '/mainCom/articleAdd',
                    component: ArticleAdd
                },

                {
                    path: '/mainCom/activityList',
                    component: ActivityList
                },
                {
                    path: '/mainCom/activityAdd',
                    component: ActivityAdd
                },
                {
                    path: '/mainCom/personList',
                    component: PersonList
                },
                {
                    path: '/mainCom/clubInfo',
                    component: ClubInfo
                },
                {
                    path: '/mainCom/applicant',
                    component: Applicant
                }
            ]
        },
    ]

})

router.beforeEach((to,from,next)=>{
    // if (to.path==='/'){
    //     next();
    // }else if (to.path === '/mainAdmin'){
    //     if (to.query.username === '张三'){
    //         next();
    //     }else {
    //         next('/')
    //     }
    // }else if (to.path === '/mainCom'){
    //     if (to.query.username === '张三'){
    //         next();
    //     }else {
    //         next('/')
    //     }
    // }
    next();

})

export default router
